

"""
    将登陆数据从txt文件提取出来，放到excel表中
"""
import openpyxl

file = open(r"C:\Users\suyujie\Desktop\测试数据\接口测试用例数据\登录接口测试用例数据.txt",'r',encoding='utf-8')
data = file.readlines()
workbook = openpyxl.load_workbook(r"C:\Users\suyujie\Desktop\登录数据.xlsx")
sheeet = workbook['Sheet1']
u,p=1,2
for i in range(2,len(data)+2):
    username = sheeet.cell(i,u)
    password = sheeet.cell(i,p)
    username.value = data[i-2].split(';')[0].strip()
    password.value = data[i-2].split(';')[1].strip()
workbook.save(r"C:\Users\suyujie\Desktop\登录数据.xlsx")
file.close()
workbook.close()
print(data)